<script>
import config from './config'
import store from '@/store'
import {
	getToken
} from '@/utils/auth'

export default {
	onLaunch: function() {
		this.initApp()
	},
	methods: {
		// 初始化应用
		initApp() {
			// 初始化应用配置
			this.initConfig()
			// 检查用户登录状态
			//#ifdef H5
			this.checkLogin()
			//#endif
		},
		initConfig() {
			this.globalData.config = config
			plus.runtime.getProperty(plus.runtime.appid, (appInfo) => {
				// 获取版本名称
				//console.log(appInfo.version);
				uni.setStorageSync('version', appInfo.version);
				// 获取版本号
				//console.log(appInfo.versionCode);
				uni.setStorageSync('versionCode', appInfo.versionCode);

			});
		},
		checkLogin() {
			if (!getToken()) {
				this.$tab.reLaunch('/pages/login')
			}
		}
	}
}
</script>

<style lang="scss">
@import '@/static/scss/index.scss'
</style>